//https://www.nowcoder.com/practice/bd7f978302044eee894445e244c7eee6?tpId=13&tqId=23272&ru=%2Fpractice%2F8fecd3f8ba334add803bf2a06af1b993&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D1%26tpId%3D13%26type%3D13
//思想：暴力求解；

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
  public:
    int NumberOf1Between1AndN_Solution(int n) {
        if (n <= 0) return 0;
        int number = 0;
        for (int i = 1; i <= n; ++i) {
            int val = i;
            while ( val != 0) {
                if (val % 10 == 1) {
                    number = number + 1;
                }
                val = val / 10;
            }

        }
        return number;

    }
};
